package com.gnerv.battle.boot.framework.core.interceptor.api;

import com.gnerv.battle.boot.framework.core.interceptor.AsyncHandlerInterceptor;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author Gnerv LiGen
 */
@Slf4j
@Component
public class ApiLogAsyncHandlerInterceptor implements AsyncHandlerInterceptor {

    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        log.info("ApiLogAsyncInterceptor preHandle");
        return preHandle(request, response, handler);
    }

    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        log.info("ApiLogAsyncInterceptor postHandle");
        postHandle(request, response, handler, modelAndView);
    }

    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        log.info("ApiLogAsyncInterceptor afterCompletion");
        afterCompletion(request, response, handler, ex);
    }
}
